<template>
  <div class="header">
  <router-link
    tag="div"
    to="/"
    class="header-abs"
    v-show="showAbs"
  >返回</router-link>
  <div class="header-fixed" v-show="!showAbs">
    <router-link to="/">
      <div class="header-fixed-back">返回</div>
    </router-link>
景点详情
  </div>
  </div>
</template>

<script>
export default {
  name: 'DetailHeader',
  data () {
    return {
      showAbs: true
    }
  },
  methods: {
    handleScroll () {
      const top = document.documentElement.scrollTop
      if (top > 60) {
        this.showAbs = false
      } else {
        this.showAbs = true
      }
    }
  },
  activated () {
    window.addEventListener('scroll', this.handleScroll)
  }
}
</script>

<style lang="stylus" scoped>
  @import '~styles/varibles.styl'
.header
  display flex
  line-height $headerHight
  background $bgColor
  color #ffffff
.header-abs
  position absolute
  left .2rem
  top .2rem
  width .8rem
  height .8rem
  line-height .8rem
  padding-left .2rem
  border-radius .4rem
  background rgba(0, 0, 0, .8)
  color #ffffff
 .header-fixed
    z-index 2
    position fixed
    top 0
    left 0
    right 0
    line-height $headerHight
    background $bgColor
    color #fff
    text-align center
    font-size .32rem
.header-fixed-back
    position absolute
    left .2rem
    color #fff
    top 0
    font-size .32rem
    color #ffffff
</style>
